import utils from '../../core/utils';

export default class messageReply {
  code: number;
  data: object;
  message: string;
  id: string;
  cursor: string;
  link: string;
  publisher: messageReply;
  name: string;
  face: string;
  mid: string;
  time_at: string;
  notify: string;
  private _title: string;

  get title() {
    var exp = /#{(.*?)}{""(.*?)""}/g;
    var item = this._title.match(exp);
    if (item[1].valueOf().length == 0) {
      return this._title;
    } else {
      this.link = item[2].valueOf();
      return `${item[1].valueOf()}${this._title.replace(item[0].valueOf(), '')}`;
    }
  }

  set title(title: string) {
    this._title = title;
  }

  private _content: string;

  get content() {
    var exp = /^#{(.*?)}{""(.*?)""}$/g;
    var item = this._content.match(exp);
    if (item[1].valueOf().length == 0) {
      return this._content;
    } else {
      if (utils.isEmpty(this.link))
        this.link = item[2].valueOf();
      return item[1].valueOf();
    }
  }

  set content(content: string) {
    this._content = content;
  }
}